import { BaseService, Post, Get } from "@/utils/http";
import type { LoginParams, LoginResult, UserInfo } from "@/types/auth";

/**
 * 认证服务类
 */
export class AuthService extends BaseService {
  @Post("/api/user/login")
  async login(params: LoginParams) {
    return this.executeMethod<LoginParams, LoginResult>(params);
  }

  @Get("/api/user/info")
  async getUserInfo() {
    return this.executeMethod<void, UserInfo>();
  }

  @Post("/api/user/logout")
  async logout() {
    return this.executeMethod<void, any>();
  }
}

// 导出服务实例
export const authService = new AuthService();

// 导出便捷方法
export const login = (params: LoginParams) => authService.login(params);
export const getUserInfo = () => authService.getUserInfo();
export const logout = () => authService.logout();
